Skip to content

Add optional character limit counter to TextField component#708

Merged
nourmalaeb merged 3 commits intodevfrom
character-limit-on-text-fields
Mar 5, 2026
Merged

Add optional character limit counter to TextField component#708
nourmalaeb merged 3 commits intodevfrom
character-limit-on-text-fields

Conversation

@nourmalaeb
Copy link
Collaborator

@nourmalaeb nourmalaeb commented Mar 4, 2026

Summary

  • Add a maxLength prop to TextField that displays a character counter (e.g., 0/50) alongside helper text or the error message
  • Counter turns bold when within 5 characters of the limit and red when the limit is reached
  • Native maxLength is also forwarded to the underlying input/textarea for browser enforcement

Test plan

  • Verify counter displays correctly with helper text (right-aligned on the same row)
  • Verify counter displays correctly with error and no helper text (same row as error)
  • Verify counter turns bold within 5 characters of the limit
  • Verify counter turns red when the limit is reached or field is invalid
  • Verify disabled state reduces counter opacity
  • Verify no visual changes when maxLength is not provided
  • Check WithCharacterLimit stories in Storybook
Screenshot showing the text field with the character limit as seen in the Storybook

@vercel
Copy link
Contributor

vercel bot commented Mar 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview Mar 4, 2026 3:42pm

Request Review

@nourmalaeb nourmalaeb merged commit a84b5c9 into dev Mar 5, 2026
14 of 15 checks passed
@nourmalaeb nourmalaeb deleted the character-limit-on-text-fields branch March 5, 2026 17:19
@scazan scazan mentioned this pull request Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants